package com.jic.weamop.weBankAMOP.common.config;

import com.jic.weamop.weBankAMOP.common.server.BaseService;
import lombok.Data;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.InputStreamReader;
import java.util.Properties;


/**
 * 配置类
 *
 * @author messigao
 *
 */

@Data
public class Config {

    private static String privKey;

    public Config() {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    }

    static {
        // 初始化一些在静态类中需要引用的静态常量，需要提前赋值，@value无法初始化
        try {
            Properties pro = new Properties();
            InputStreamReader in = new InputStreamReader(BaseService.class.getResourceAsStream("/application.properties"));
            pro.load(in);

            //给静态变量赋值
            privKey = pro.getProperty("privKey");

        } catch (Exception e) {
            System.out.println("初始化失败");
        }
    }

    public static String getPrivKey() {
          return privKey;
    }

}


